<template>
  <div id="app">
    <router-view />
  </div>
</template>


<script>

// import { ElConfigProvider } from "element-plus";
// import zhCn from "element-plus/lib/locale/lang/zh-cn";
// import jwt_decode from "jwt-decode";
// import { useStore } from "vuex";
// import { onMounted } from "vue";
// // const store = useStore();

// // 判断是否为空的方法
// const isEmpty = (value) => {
//   return (
//     value === undefined ||
//     value === null ||
//     (typeof value === "object" && Object.keys(value).length === 0) ||
//     (typeof value === "string" && value.trim().length === 0)
//   );
// };

// onMounted(() => {
//   if (localStorage.eleToken) {
//     const decoded = jwt_decode(localStorage.eleToken);
//     // token存储到vuex中
//     this.$store.dispatch("setAuthenticated", !isEmpty(decoded));
//     this.$store.dispatch("setUser", decoded);
//   }
// });


// import { type } from 'os';
import jwt_decode from "jwt-decode";
export default {
  name: 'app',
  components: {},
  created() {
    if (localStorage.eleToken) {
      const decoded = jwt_decode(localStorage.eleToken)
      this.$store.dispatch('setAuthenticated', !this.isEmpty(decoded));
      this.$store.dispatch('setUser', decoded)
    }
  },
  methods: {
    isEmpty(value) {
      return (
        value === undefined ||
        value === null ||
        (typeof value === "object" && Object.keys(value).length === 0) ||
        (typeof value === "string" && Object.trim().length === 0)
      )
    }
  }
};
</script>

<style>
html,
body,
#app {
  width: 100%;
  height: 100%;
}
</style>
